package com.weetop.aklyscan.presenter;

import android.app.Activity;

import com.weetop.aklyscan.base.mvp.BaseModel;
import com.weetop.aklyscan.base.mvp.BaseObserver;
import com.weetop.aklyscan.base.mvp.BasePresenter;
import com.weetop.aklyscan.bean.ChaXunBean;
import com.weetop.aklyscan.bean.ChanpinChukuBean;
import com.weetop.aklyscan.bean.InStockItemBean;
import com.weetop.aklyscan.bean.ProductInfo;
import com.weetop.aklyscan.bean.TransferBoxBean;
import com.weetop.aklyscan.bean.TypeInfo;
import com.weetop.aklyscan.bean.ZXGoodsInfo;
import com.weetop.aklyscan.bean.ZXOrderInfo;
import com.weetop.aklyscan.view.ZxProductView;

import org.json.JSONArray;

import java.util.List;

public class ZxProductPresent extends BasePresenter<ZxProductView> {

    public ZxProductPresent(ZxProductView baseView, Activity activity) {
        super(baseView, activity);
    }

    public void searchList(String code) {
        addDisposable(apiServer.scanTransferBox(code), new BaseObserver<BaseModel<TransferBoxBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<TransferBoxBean> o) {
                baseView.getSearchResultSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void scanProduct(String goods_sn) {
        addDisposable(apiServer.getProductInfo(goods_sn), new BaseObserver<BaseModel<ProductInfo>>(baseView) {
            @Override
            public void onSuccess(BaseModel<ProductInfo> o) {
                baseView.getProductInfSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void saveZx(String barcode) {
        addDisposable(apiServer.into01(barcode), new BaseObserver<BaseModel<Object>>(baseView) {
            @Override
            public void onSuccess(BaseModel<Object> o) {
                baseView.saveZxSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }

    public void Into08(String type, String serial_code, String order_sn) {
        addDisposable(apiServer.Into08(type, serial_code, order_sn), new BaseObserver<BaseModel<ZXGoodsInfo>>(baseView) {
            @Override
            public void onSuccess(BaseModel<ZXGoodsInfo> o) {
                baseView.getInto08Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onError();
                }
            }
        });
    }

    public void Into09(String orderId, String type, String barcode, JSONArray serial_code_items) {
        addDisposable(apiServer.Into09(orderId, type, barcode, serial_code_items), new BaseObserver<BaseModel<Object>>(baseView) {
            @Override
            public void onSuccess(BaseModel<Object> o) {
                baseView.getInto09Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onUpFail(msg);
                }
            }
        });
    }

    public void Into12(String shop_type, String order_type, String port_type, String order_sn) {
        addDisposable(apiServer.Into12(shop_type, order_type, port_type,order_sn), new BaseObserver<BaseModel<List<ZXOrderInfo>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<List<ZXOrderInfo>> o) {
                baseView.getInto12Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onUpFail(msg);
                }
            }
        });
    }

    public void Into26(String type) {
        addDisposable(apiServer.Into26(type), new BaseObserver<BaseModel<List<TypeInfo>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<List<TypeInfo>> o) {
                baseView.getInto26Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into18() {
        addDisposable(apiServer.Into18(), new BaseObserver<BaseModel<List<TypeInfo>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<List<TypeInfo>> o) {
                baseView.getInto18Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into19(String order_type, String order_sn, final String code, String num) {
        addDisposable(apiServer.Into19(order_type, order_sn, code, num), new BaseObserver<BaseModel<Object>>(baseView) {
            @Override
            public void onSuccess(BaseModel<Object> o) {
                baseView.getInto19Success(o, code);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onError();
                }
            }
        });
    }

    public void Into20(JSONArray items) {
        addDisposable(apiServer.Into20(items), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getInto20Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onUpFail(msg);
                }
            }
        });
    }

    public void Into21(JSONArray items,String order_sn) {
        addDisposable(apiServer.Into21(items,order_sn), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getInto21Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onUpFail(msg);
                }
            }
        });
    }

    public void Into22(String case_code) {
        addDisposable(apiServer.Into22(case_code), new BaseObserver<BaseModel<List<ChanpinChukuBean>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<List<ChanpinChukuBean>> o) {
                baseView.getInto22Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onError();
                }
            }
        });
    }

    public void Into25(String order_type, String order_sn) {
        addDisposable(apiServer.Into25(order_type, order_sn), new BaseObserver<BaseModel<Object>>(baseView) {
            @Override
            public void onSuccess(BaseModel<Object> o) {
                baseView.getInto25Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }
    public void Into31(JSONArray items, String order_sn) {
        addDisposable(apiServer.Into31(items, order_sn), new BaseObserver<BaseModel<List<ChaXunBean>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<List<ChaXunBean>> o) {
                baseView.getInto31Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }
    public void Into32(String order_sn) {
        addDisposable(apiServer.Into32(order_sn), new BaseObserver<BaseModel<List<ZXOrderInfo>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<List<ZXOrderInfo>> o) {
                baseView.getInto32Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }
    public void Into33(String barcode) {
        addDisposable(apiServer.Into33(barcode), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getInto33Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }

    public void Into36(JSONArray items, String order_sn) {
        addDisposable(apiServer.Into36(items, order_sn), new BaseObserver<BaseModel<List<ChaXunBean>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<List<ChaXunBean>> o) {
                baseView.getInto36Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }

    public void Into46(String serial_code) {
        addDisposable(apiServer.Into46(serial_code), new BaseObserver<BaseModel<InStockItemBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<InStockItemBean> o) {
                baseView.getInto46Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }
}
